<template>
  <div>
    <el-form ref="form" :model="form" label-width="100px">
      <el-row>
        <el-col :span="6" o>
          <el-form-item label="【题型】：">
            <div>
              <span v-if="form.questionType === '1'">单选</span>
              <span v-else-if="form.questionType === '2'">多选</span>
              <span v-else-if="form.questionType === '3'">简答</span>
            </div>
          </el-form-item></el-col
        >
        <el-col :span="6">
          <el-form-item label="【编号】：">
            <div v-html="form.id"></div> </el-form-item
        ></el-col>
        <el-col :span="6">
          <el-form-item label="【难度】：">
            <div>
              <span v-if="form.difficulty === '1'">简单</span>
              <span v-else-if="form.difficulty === '2'">一般</span>
              <span v-else-if="form.difficulty === '3'">困难</span></div> </el-form-item
        ></el-col>
        <el-col :span="6">
          <el-form-item label="【标签】：">
            <div v-html="form.tags"></div> </el-form-item
        ></el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="【学科】：">
            <div v-html="form.subjectName"></div> </el-form-item
        ></el-col>
        <el-col :span="6">
          <el-form-item label="【目录】：">
            <div v-html="form.directoryName"></div> </el-form-item
        ></el-col>
        <el-col :span="10">
          <el-form-item label="【方向】：">
            <div v-html="form.direction"></div> </el-form-item
        ></el-col>
        <el-col :span="6"></el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="24">
          <el-form-item label="【题干】：">
            <div style="width: 100%; height: 25px"></div>
            <div style="width: 100%; color: #0101ff" id="formItemInP">
              <div v-html="form.question" style="color: #0101ff"></div>
              <div>
                <div v-if="form.questionType === '1'">
                  <template>
                    <el-radio-group v-model="randomsRadio">
                      <el-radio
                        :label="item.isRight"
                        @change="randomsRadio=1"
                        v-model="randomsRadio"
                        :key="item.id"
                        v-for="item in form.options"
                        style="display: block; margin-bottom: 18px"
                        >{{ item.code }}. {{ item.title }}</el-radio
                      >
                    </el-radio-group>
                  </template>
                </div>
                <div v-else-if="form.questionType === '2'">
                  <template>

                      <el-checkbox
                        :label="item.isRight"
                        @change="randomsCheckList=[1]"
                        v-model="randomsCheckList"
                        :key="item.id"
                        v-for="item in form.options"
                        style="display: block"
                        >{{ item.title }}</el-checkbox
                      >

                  </template>
                </div>
              </div>
            </div>
          </el-form-item>
        </el-col>
      </el-row>
      <el-divider></el-divider>
      <el-row>
        <el-col :span="3">
          <el-form-item label="【参考答案】：" label-width="120px">
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-button type="danger" @click="isVideo = true"
            >显示参考答案</el-button
          >
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <video v-if="isVideo" width="200px" height="200px">
            <source src="https://v-cdn.zjol.com.cn/277004.mp4" /></video
        ></el-col>
      </el-row>
       <el-divider></el-divider>
      <el-row>
        <el-col :span="24">
          <el-form-item label="【答案解析】：" label-width="120px">
            <div v-html="form.answer" ></div> </el-form-item
        ></el-col>
      </el-row>
       <el-divider></el-divider>
       <el-row>
        <el-col :span="24">
          <el-form-item label="【题目备注】：" label-width="120px">
            <div v-html="form.remarks" ></div> </el-form-item
        ></el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { detail } from '@/api/hmmm/questions'
export default {
  props: ['id'],
  data () {
    return {
      // 表单数据
      form: {
        questionType: '',
        id: '',
        difficulty: '',
        tags: '',
        subjectName: '',
        directoryName: '',
        direction: '',
        question: '',
        options: '',
        answer: '',
        remarks: ''

      },
      randomsRadio: 1, // 单选框
      randomsCheckList: [1], // 复选框
      isRight: 0,
      isVideo: false
    }
  },
  //   created () {
  //     this.select(this.form)
  //   },

  watch: {
    id () {
      this.getlists()
    }
  },
  mounted () {},
  methods: {
    // select (val) {
    //   if (val.questionType === '1') {
    //     val.options.forEach((item) => {
    //       if (item.isRight) {
    //         this.randomsRadio = item.isRight
    //       }
    //     })
    //   } else if (val.questionType === '2') {
    //     val.options.forEach((item) => {
    //       if (item.isRight) {
    //         this.randomsCheckList.push(item.isRight)
    //       }
    //     })
    //   }
    // },

    // 获取列表
    async getlists () {
      const res = await detail({ id: this.id })
      console.log(res)
      this.form = res.data
    }
  }
}
</script>

<style lang="scss" scoped>
#formItemInP p {
  margin-left: 0px;
}
</style>
